/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {number[][]} descriptions
 * @return {TreeNode}
 */
 var createBinaryTree = function(descriptions) {
  const g = {}
  const hasFather = new Set()
  for(const [f, t, isLeft] of descriptions) {
    g[f] = g[f] || new TreeNode(f)
    g[t] = g[t] || new TreeNode(t)
    hasFather.add(String(t))
    if(isLeft) g[f].left = g[t]
    else g[f].right = g[t]
  }
  for(const key in g) {
    if(!hasFather.has(key)){
      return g[key]
    }
  }
  return null
};